﻿#region License
/*
 *CopyRight (c) By Denuvead All Rights Reserved
 *CreateDate:
 *Info:
 */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PriErp.Tools.Extensions
{
    /// <summary>
    /// 扩展类
    /// </summary>
    public static partial class PriErpExtension
    {
        /// <summary>
        /// 判断是否有值
        /// </summary>
        /// <typeparam name="T">List类型</typeparam>
        /// <param name="list">List</param>
        /// <returns>返回是否含有值</returns>
        static public bool HasVal<T>(this List<T> list)
        {
            return list != null && list.Count > 0;
        }
        /// <summary>
        /// 连接集合值
        /// </summary>
        /// <typeparam name="T">List类型</typeparam>
        /// <param name="list">List</param>
        /// <param name="uninchar">连接字符</param>
        /// <returns>返回连接后的字符</returns>
        static public string ToUninString<T>(this List<T> list, char uninchar)
        {
            StringBuilder sVal = new StringBuilder();
            if (list.HasVal())
            {
                list.ForEach(item => sVal.AppendFormat("{0}{1}", item, uninchar));
                sVal.Remove(sVal.Length - 1, 1);
            }
            return sVal.ToString();
        }
    }
}
